import {
    Platform,
    ToastAndroid,
    RefreshControl
} from 'react-native'
import React, { Component } from 'react'


export function myAlert(msg){
    if(Platform.OS === 'ios'){
        //ios相关操作
        alert(msg);
    }else{
        //android相关操作
        ToastAndroid.show(msg, ToastAndroid.SHORT);
    }
}


export class MyRefreshControl  extends Component {

    constructor(props) {          
        super(props);
    };

    render() {
        if(Platform.OS === 'ios'){
            //ios相关操作
            return(
            <RefreshControl  
            refreshing={this.props.isRefreshing}  
             onRefresh={this._onRefresh}  
             tintColor={['#ff0000', '#00ff00','#0000ff','#3ad564']}  
            progressBackgroundColor="#ffffff"  
           />
            )
        }else{
            //android相关操作
            return(
                <RefreshControl  
                refreshing={this.props.isRefreshing}  
                onRefresh={this._onRefresh}  
                colors={['#ff0000', '#00ff00','#0000ff','#3ad564']}  
                progressBackgroundColor="#ffffff"  
            />
            )
        }
    }

    _onRefresh(){
        //console.log(this);
    }
}
